package android.support.v4.app;


/**
 * http://stackoverflow.com/questions/23504790/android-multiple-fragment-transaction-ordering
 * 这个解决 fragment中有A1,B1,C1,需要移除后添加入A2,B2,C2,结果展示的事C2,B2,A2的问题，正常情况下是A2,B2,C2
 */
public class FragmentTransactionBugFixHack {

    public static void reorderIndices(FragmentManager fragmentManager) {
        if (!(fragmentManager instanceof FragmentManagerImpl))
            return;
        try {
            FragmentManagerImpl fragmentManagerImpl = (FragmentManagerImpl) fragmentManager;
//            if (fragmentManagerImpl.mAvailBackStackIndices != null && fragmentManagerImpl.mAvailIndices.size() > 1) {
////                System.out.println("排序前-->" + fragmentManagerImpl.mAvailIndices);
//                Collections.sort(fragmentManagerImpl.mAvailIndices, Collections.reverseOrder());
////                System.out.println("排序后-->" + fragmentManagerImpl.mAvailIndices);
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}